package com.wyh.yuhcloud.core;

import java.io.Serializable;

/**
 * 统一返回结果格式，定义结果集
 *
 * @author wyh
 * @version 1.0
 */
public class Result implements Serializable {

    private static final long serialVersionUID = 1L;
    /**
     * 返回0成功，其他代码为失败
     */
    private Integer code;
    /**
     * 消息内容，code为非0时返回消息
     */
    private String msg;
    /**
     * 返回结果集
     */
    private Object data;

    /**
     * 默认构造为成功
     */
    public Result() {
        this.code = 200;
        this.msg = "成功";
    }

    /**
     * 构造成功并加入数据
     */
    public Result(Object data) {
        this();
        this.data = data;
    }

    /**
     * 失败的构造方法
     */
    public Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}

